package com.LC.DAO;


import com.LC.Entity.OrderSetting;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

@Mapper
public interface OrderSettingDAO {
    /**
     * 根据预约日期查询出现次数
     * @param orderDate
     * @return
     */
    @Select("select count(*) from t_ordersetting where orderDate = #{orderDate}")
    public int findCountByOrderDate(Date orderDate);

    /**
     * 新增预约设置
     * @param orderSettings
     */
    @Insert("insert into t_ordersetting(orderDate,number) value(#{orderDate},#{number})")
    public void addOrderSetting(OrderSetting orderSettings);

    /**
     * 更新预约设置
     * @param orderSetting
     */
    @Update("update t_ordersetting set number = #{number} where orderDate = #{orderDate}")
    public void editOrderSetting(OrderSetting orderSetting);

    /**
     * 根据月查询信息
     * @param dateBegin
     * @param dateEnd
     * @return
     */
    @Select("select * from t_ordersetting where orderDate between STR_TO_DATE(#{dateBegin},'%Y-%m-%d') AND STR_TO_DATE(#{dateEnd},'%Y-%m-%d')")
    public List<OrderSetting> getOrderSettingByMonth(@Param("dateBegin") String dateBegin, @Param("dateEnd") String dateEnd);
    
    @Update("update t_ordersetting set reservations = #{newReservation} where orderDate = STR_TO_DATE(#{date},'%Y-%m-%d')")
    public void upDateReservations(@Param("newReservation") int newReservation, @Param("date") String date);
    
   
}
